<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>第2节：基本使用 | 数据分析课件</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../chapter4/03条形图.html" />
    
    
    <link rel="prev" href="../chapter4/01常用图.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="4.2"
        data-chapter-title="第2节：基本使用"
        data-filepath="chapter4/02基本使用.md"
        data-basepath=".."
        data-revision="Wed Jul 17 2019 11:42:54 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="chapter0/00.html">
            
                
                    <a href="../chapter0/00.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        第一章：数据分析前奏
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="chapter0/01什么是数据分析.html">
            
                
                    <a href="../chapter0/01什么是数据分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        第1节：什么是数据分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="chapter0/02环境搭建.html">
            
                
                    <a href="../chapter0/02环境搭建.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        第2节：环境搭建
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="chapter0/03jupyternotebook使用.html">
            
                
                    <a href="../chapter0/03jupyternotebook使用.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        第3节：jupyternotebook使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="chapter0/04作业.html">
            
                
                    <a href="../chapter0/04作业.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        第4节：作业
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="chapter1/00.html">
            
                
                    <a href="../chapter1/00.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        第二章：Numpy库
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="chapter1/01numpy库介绍.html">
            
                
                    <a href="../chapter1/01numpy库介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        第1节：numpy库介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="chapter1/02numpy数组基本.html">
            
                
                    <a href="../chapter1/02numpy数组基本.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        第2节：numpy数组基本
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="chapter1/03numpy数组操作.html">
            
                
                    <a href="../chapter1/03numpy数组操作.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        第3节：numpy数组操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="chapter1/03numpy索引和切片.html">
            
                
                    <a href="../chapter1/03numpy索引和切片.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        第4节：numpy索引和切片
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="chapter1/04Numpy索引和切片作业.html">
            
                
                    <a href="../chapter1/04Numpy索引和切片作业.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        第5节：Numpy索引和切片作业
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="chapter1/05numpy数组操作.html">
            
                
                    <a href="../chapter1/05numpy数组操作.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        第6节：numpy数组操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="chapter1/06深拷贝和浅拷贝.html">
            
                
                    <a href="../chapter1/06深拷贝和浅拷贝.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.</b>
                        
                        第7节：深拷贝和浅拷贝
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="chapter1/07文件操作.html">
            
                
                    <a href="../chapter1/07文件操作.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.8.</b>
                        
                        第8节：文件操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.9" data-path="chapter1/08数组操作和文件操作作业.html">
            
                
                    <a href="../chapter1/08数组操作和文件操作作业.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.9.</b>
                        
                        第9节：数组操作和文件操作作业.md
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.10" data-path="chapter1/09NAN和INF值处理.html">
            
                
                    <a href="../chapter1/09NAN和INF值处理.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.10.</b>
                        
                        第10节：NAN和INF值处理.md
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.11" data-path="chapter1/10random模块.html">
            
                
                    <a href="../chapter1/10random模块.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.11.</b>
                        
                        第11节：random模块.md
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.12" data-path="chapter1/11axis理解.html">
            
                
                    <a href="../chapter1/11axis理解.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.12.</b>
                        
                        第12节：axis理解.md
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.13" data-path="chapter1/12通用函数.html">
            
                
                    <a href="../chapter1/12通用函数.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.13.</b>
                        
                        第13节：通用函数.md
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.14" data-path="chapter1/13numpy练习题.html">
            
                
                    <a href="../chapter1/13numpy练习题.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.14.</b>
                        
                        第14节：numpy练习题.md
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="chapter2/00.html">
            
                
                    <a href="../chapter2/00.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        第三章：Pandas库
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="chapter2/01pandas介绍.html">
            
                
                    <a href="../chapter2/01pandas介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        第1节：pandas介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="chapter2/02pandas索引操作.html">
            
                
                    <a href="../chapter2/02pandas索引操作.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        第2节：pandas索引操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="chapter2/03pandas对齐运算.html">
            
                
                    <a href="../chapter2/03pandas对齐运算.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        第3节：pandas对齐运算
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="chapter2/04pandas函数应用.html">
            
                
                    <a href="../chapter2/04pandas函数应用.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        第4节：pandas函数应用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="chapter2/05pandas层级索引.html">
            
                
                    <a href="../chapter2/05pandas层级索引.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        第5节：pandas层级索引
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="chapter2/06pandas统计计算和描述.html">
            
                
                    <a href="../chapter2/06pandas统计计算和描述.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        第6节：pandas统计计算和描述
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="chapter2/07文件操作.html">
            
                
                    <a href="../chapter2/07文件操作.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.7.</b>
                        
                        第7节：文件操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="chapter2/08数据清洗.html">
            
                
                    <a href="../chapter2/08数据清洗.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.8.</b>
                        
                        第8节：数据清洗
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.9" data-path="chapter2/09聚合和分组.html">
            
                
                    <a href="../chapter2/09聚合和分组.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.9.</b>
                        
                        第9节：聚合和分组
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.10" data-path="chapter2/10时间序列.html">
            
                
                    <a href="../chapter2/10时间序列.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.10.</b>
                        
                        第10节：时间序列
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="chapter4/00.html">
            
                
                    <a href="../chapter4/00.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        第四章：Matploblib库
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="chapter4/01常用图.html">
            
                
                    <a href="../chapter4/01常用图.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        第1节：常用图
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="4.2" data-path="chapter4/02基本使用.html">
            
                
                    <a href="../chapter4/02基本使用.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        第2节：基本使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="chapter4/03条形图.html">
            
                
                    <a href="../chapter4/03条形图.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.</b>
                        
                        第3节：条形图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="chapter4/04直方图.html">
            
                
                    <a href="../chapter4/04直方图.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        第4节：直方图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="chapter4/05散点图.html">
            
                
                    <a href="../chapter4/05散点图.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.</b>
                        
                        第5节：散点图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="chapter4/06饼图.html">
            
                
                    <a href="../chapter4/06饼图.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.6.</b>
                        
                        第6节：饼图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="chapter4/07箱线图.html">
            
                
                    <a href="../chapter4/07箱线图.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.7.</b>
                        
                        第7节：箱线图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="chapter4/08雷达图.html">
            
                
                    <a href="../chapter4/08雷达图.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.8.</b>
                        
                        第8节：雷达图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.9" data-path="chapter4/09matplotlib绘图分析.html">
            
                
                    <a href="../chapter4/09matplotlib绘图分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.9.</b>
                        
                        第9节：matplotlib绘图分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.10" data-path="chapter4/10多图布局.html">
            
                
                    <a href="../chapter4/10多图布局.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.10.</b>
                        
                        第10节：多图布局
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.11" data-path="chapter4/11matplotlib配置.html">
            
                
                    <a href="../chapter4/11matplotlib配置.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.11.</b>
                        
                        第11节：matplotlib配置
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.12" data-path="chapter4/12matplotlib作业.html">
            
                
                    <a href="../chapter4/12matplotlib作业.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.12.</b>
                        
                        第12节：matplotlib作业
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="chapter5/00.html">
            
                
                    <a href="../chapter5/00.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        第五章：Seaborn库
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="chapter5/01关系绘图.html">
            
                
                    <a href="../chapter5/01关系绘图.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        第1节：关系绘图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="chapter5/02分类绘图.html">
            
                
                    <a href="../chapter5/02分类绘图.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        第2节：分类绘图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="chapter5/03分布绘图.html">
            
                
                    <a href="../chapter5/03分布绘图.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        第3节：分布绘图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="chapter5/04线性关系绘图.html">
            
                
                    <a href="../chapter5/04线性关系绘图.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        第4节：线性关系绘图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="chapter5/05FacetGrid结构图.html">
            
                
                    <a href="../chapter5/05FacetGrid结构图.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        第5节：FacetGrid结构图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="chapter5/06样式设置.html">
            
                
                    <a href="../chapter5/06样式设置.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.6.</b>
                        
                        第6节：样式设置
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="chapter5/07调色盘设置.html">
            
                
                    <a href="../chapter5/07调色盘设置.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.7.</b>
                        
                        第7节：调色盘设置
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8" data-path="chapter5/08seaborn作业.html">
            
                
                    <a href="../chapter5/08seaborn作业.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.</b>
                        
                        第8节：seaborn作业
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="chapter3/00.html">
            
                
                    <a href="../chapter3/00.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        第六章：统计分析强化
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="chapter3/01常用专业数学术语.html">
            
                
                    <a href="../chapter3/01常用专业数学术语.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        第1节：常用专业数学术语
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="chapter3/02平均数.html">
            
                
                    <a href="../chapter3/02平均数.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        第2节：平均数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="chapter3/03方差和标准差.html">
            
                
                    <a href="../chapter3/03方差和标准差.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                        第3节：方差和标准差
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="chapter3/04正态分布.html">
            
                
                    <a href="../chapter3/04正态分布.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        第4节：正态分布
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="chapter3/05对比分析.html">
            
                
                    <a href="../chapter3/05对比分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.5.</b>
                        
                        第5节：对比分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.6" data-path="chapter3/06分布分析.html">
            
                
                    <a href="../chapter3/06分布分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.6.</b>
                        
                        第6节：分布分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.7" data-path="chapter3/07交叉分析.html">
            
                
                    <a href="../chapter3/07交叉分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.7.</b>
                        
                        第7节：交叉分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.8" data-path="chapter3/08统计分析.html">
            
                
                    <a href="../chapter3/08统计分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.8.</b>
                        
                        第8节：统计分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.9" data-path="chapter3/09帕累托分析.html">
            
                
                    <a href="../chapter3/09帕累托分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.9.</b>
                        
                        第9节：帕累托分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.10" data-path="chapter3/10矩阵关联分析.html">
            
                
                    <a href="../chapter3/10矩阵关联分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.10.</b>
                        
                        第10节：矩阵关联分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.11" data-path="chapter3/11综合性分析.html">
            
                
                    <a href="../chapter3/11综合性分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.11.</b>
                        
                        第11节：综合性分析
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7" data-path="chapter6/00.html">
            
                
                    <a href="../chapter6/00.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        第七章：数据分析实战
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.1" data-path="chapter6/01App数据分析实战.html">
            
                
                    <a href="../chapter6/01App数据分析实战.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.1.</b>
                        
                        第1节：App数据分析实战
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="chapter6/02心脏病患者数据分析.html">
            
                
                    <a href="../chapter6/02心脏病患者数据分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.2.</b>
                        
                        第2节：心脏病患者数据分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="chapter6/03StackoverFlow数据分析.html">
            
                
                    <a href="../chapter6/03StackoverFlow数据分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.3.</b>
                        
                        第3节：StackoverFlow数据分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.4" data-path="chapter6/04二手房数据分析.html">
            
                
                    <a href="../chapter6/04二手房数据分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.4.</b>
                        
                        第4节：二手房数据分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.5" data-path="chapter6/05吃鸡数据分析.html">
            
                
                    <a href="../chapter6/05吃鸡数据分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.</b>
                        
                        第5节：吃鸡数据分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.6" data-path="chapter6/06黑色星期五数据分析.html">
            
                
                    <a href="../chapter6/06黑色星期五数据分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.6.</b>
                        
                        第6节：黑色星期五数据分析
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="8" data-path="chapter7/00.html">
            
                
                    <a href="../chapter7/00.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        第八章：补充
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="8.1" data-path="chapter7/01用Excel做数据分析.html">
            
                
                    <a href="../chapter7/01用Excel做数据分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.1.</b>
                        
                        第1节：用Excel做数据分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.2" data-path="chapter7/02echarts和pyecharts库.html">
            
                
                    <a href="../chapter7/02echarts和pyecharts库.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.2.</b>
                        
                        第2节：echarts和pyecharts库
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.3" data-path="chapter7/03bokeh库.html">
            
                
                    <a href="../chapter7/03bokeh库.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.3.</b>
                        
                        第3节：bokeh库
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

   
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="matplotlib&#x5E93;">Matplotlib&#x5E93;</h1>
<p><code>Matplotlib</code>&#x662F;&#x4E00;&#x4E2A;<code>Python</code>&#x7684;<code>2D</code>&#x7ED8;&#x56FE;&#x5E93;&#xFF0C;&#x901A;&#x8FC7;<code>Matplotlib</code>&#xFF0C;&#x5F00;&#x53D1;&#x8005;&#x53EF;&#x4EE5;&#x4EC5;&#x9700;&#x8981;&#x51E0;&#x884C;&#x4EE3;&#x7801;&#xFF0C;&#x4FBF;&#x53EF;&#x4EE5;&#x751F;&#x6210;&#x6298;&#x7EBF;&#x56FE;&#xFF0C;&#x76F4;&#x65B9;&#x56FE;&#xFF0C;&#x6761;&#x5F62;&#x56FE;&#xFF0C;&#x997C;&#x72B6;&#x56FE;&#xFF0C;&#x6563;&#x70B9;&#x56FE;&#x7B49;&#x3002;</p>
<h2 id="&#x5B89;&#x88C5;&#xFF1A;">&#x5B89;&#x88C5;&#xFF1A;</h2>
<p>&#x5982;&#x679C;&#x662F;&#x7528;<code>Anaconda</code>&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>conda install matplotlib</code>&#x6216;&#x8005;&#x901A;&#x8FC7;<code>pip install matplotlib</code>&#x8FDB;&#x884C;&#x5B89;&#x88C5;&#x3002;</p>
<h2 id="&#x57FA;&#x672C;&#x4F7F;&#x7528;&#xFF1A;">&#x57FA;&#x672C;&#x4F7F;&#x7528;&#xFF1A;</h2>
<p>&#x9996;&#x5148;&#x5148;&#x770B;&#x4EE5;&#x4E0B;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
plt.plot(range(<span class="hljs-number">10</span>),[np.random.randint(<span class="hljs-number">0</span>,<span class="hljs-number">10</span>) <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> range(<span class="hljs-number">10</span>)])
</code></pre>
<p>&#x90A3;&#x4E48;&#x5C31;&#x4F1A;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x56FE;&#xFF1A;<br><img src="../assets/matplotlib1.png" alt=""><br>&#x5176;&#x4E2D;<code>plot</code>&#x662F;&#x4E00;&#x4E2A;&#x753B;&#x56FE;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x4ED6;&#x7684;&#x53C2;&#x6570;&#x4E3A;<code>plot([x],y,[fmt],data=None,**kwargs)</code>&#x3002;&#x5176;&#x4E2D;<code>fmt</code>&#x53EF;&#x4EE5;&#x4F20;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x7528;&#x6765;&#x7ED9;&#x8FD9;&#x4E2A;&#x56FE;&#x505A;&#x4E00;&#x4E9B;&#x6837;&#x5F0F;&#x4FEE;&#x6539;&#x7684;&#x3002;&#x9ED8;&#x8BA4;&#x7684;&#x7ED8;&#x5236;&#x6837;&#x5F0F;&#x662F;<code>b-</code>&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x84DD;&#x8272;&#x5B9E;&#x4F53;&#x7EBF;&#x6761;&#x3002;&#x6BD4;&#x5982;&#x6211;&#x60F3;&#x5C06;&#x539F;&#x6765;&#x7684;&#x56FE;&#x7684;&#x7EBF;&#x6761;&#x6539;&#x6210;&#x70B9;&#x72B6;&#xFF0C;&#x90A3;&#x4E48;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4EE5;&#x4E0B;&#x4EE3;&#x7801;&#x5B9E;&#x73B0;&#xFF1A;</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt
plt.plot(range(<span class="hljs-number">10</span>),[np.random.randint(<span class="hljs-number">0</span>,<span class="hljs-number">10</span>) <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> range(<span class="hljs-number">10</span>)],<span class="hljs-string">&quot;:&quot;</span>)
</code></pre>
<p>&#x5176;&#x4E2D;&#x4F7F;&#x7528;<code>:</code>&#x4EE3;&#x8868;&#x70B9;&#x7EBF;&#xFF0C;&#x662F;<code>matplotlib</code>&#x7684;&#x4E00;&#x4E2A;&#x7F29;&#x5199;&#x3002;&#x8FD9;&#x4E9B;&#x7F29;&#x5199;&#x8FD8;&#x6709;&#x4EE5;&#x4E0B;&#x7684;&#xFF1A;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x5B57;&#x7B26;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x5B57;&#x7B26;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">&apos;-&apos;</td>
<td style="text-align:left">&#x5B9E;&#x7EBF;</td>
<td style="text-align:left">&apos;--&apos;</td>
<td style="text-align:left">&#x865A;&#x7EBF;</td>
</tr>
<tr>
<td style="text-align:left">&apos;-.&apos;</td>
<td style="text-align:left">&#x865A;&#x70B9;&#x7EBF;</td>
<td style="text-align:left">&apos;:&apos;</td>
<td style="text-align:left">&#x70B9;&#x7EBF;</td>
</tr>
<tr>
<td style="text-align:left">&apos;.&apos;</td>
<td style="text-align:left">&#x70B9;</td>
<td style="text-align:left">&apos;,&apos;</td>
<td style="text-align:left">&#x50CF;&#x7D20;&#x70B9;</td>
</tr>
<tr>
<td style="text-align:left">&apos;o&apos;</td>
<td style="text-align:left">&#x5706;&#x70B9;</td>
<td style="text-align:left">&apos;v&apos;</td>
<td style="text-align:left">&#x4E0B;&#x4E09;&#x89D2;&#x70B9;</td>
</tr>
<tr>
<td style="text-align:left">&apos;^&apos;</td>
<td style="text-align:left">&#x4E0A;&#x4E09;&#x89D2;&#x70B9;</td>
<td style="text-align:left">&apos;&lt;&apos;</td>
<td style="text-align:left">&#x5DE6;&#x4E09;&#x89D2;&#x70B9;</td>
</tr>
<tr>
<td style="text-align:left">&apos;&gt;&apos;</td>
<td style="text-align:left">&#x53F3;&#x4E09;&#x89D2;&#x70B9;</td>
<td style="text-align:left">&apos;1&apos;</td>
<td style="text-align:left">&#x4E0B;&#x4E09;&#x53C9;&#x70B9;</td>
</tr>
<tr>
<td style="text-align:left">&apos;2&apos;</td>
<td style="text-align:left">&#x4E0A;&#x4E09;&#x53C9;&#x70B9;</td>
<td style="text-align:left">&apos;3&apos;</td>
<td style="text-align:left">&#x5DE6;&#x4E09;&#x53C9;&#x70B9;</td>
</tr>
<tr>
<td style="text-align:left">&apos;4&apos;</td>
<td style="text-align:left">&#x53F3;&#x4E09;&#x53C9;&#x70B9;</td>
<td style="text-align:left">&apos;s&apos;</td>
<td style="text-align:left">&#x6B63;&#x65B9;&#x70B9;</td>
</tr>
<tr>
<td style="text-align:left">&apos;p&apos;</td>
<td style="text-align:left">&#x4E94;&#x89D2;&#x70B9;</td>
<td style="text-align:left">&apos;*&apos;</td>
<td style="text-align:left">&#x661F;&#x5F62;&#x70B9;</td>
</tr>
<tr>
<td style="text-align:left">&apos;h&apos;</td>
<td style="text-align:left">&#x516D;&#x8FB9;&#x5F62;&#x70B9;1</td>
<td style="text-align:left">&apos;H&apos;</td>
<td style="text-align:left">&#x516D;&#x8FB9;&#x5F62;&#x70B9;2</td>
</tr>
<tr>
<td style="text-align:left">&apos;+&apos;</td>
<td style="text-align:left">&#x52A0;&#x53F7;&#x70B9;</td>
<td style="text-align:left">&apos;x&apos;</td>
<td style="text-align:left">&#x4E58;&#x53F7;&#x70B9;</td>
</tr>
<tr>
<td style="text-align:left">&apos;D&apos;</td>
<td style="text-align:left">&#x5B9E;&#x5FC3;&#x83F1;&#x5F62;&#x70B9;</td>
<td style="text-align:left">&apos;d&apos;</td>
<td style="text-align:left">&#x7626;&#x83F1;&#x5F62;&#x70B9;</td>
</tr>
<tr>
<td style="text-align:left">&apos;_&apos;</td>
<td style="text-align:left">&#x6A2A;&#x7EBF;&#x70B9;</td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<p>&#x9664;&#x4E86;&#x8BBE;&#x7F6E;&#x7EBF;&#x6761;&#x7684;&#x5F62;&#x72B6;&#x5916;&#xFF0C;&#x6211;&#x4EEC;&#x8FD8;&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x70B9;&#x7684;&#x989C;&#x8272;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python">plt.plot([<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>],[<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>],<span class="hljs-string">&apos;r&apos;</span>) <span class="hljs-comment">#&#x5C06;&#x989C;&#x8272;&#x7EBF;&#x6761;&#x8BBE;&#x7F6E;&#x6210;&#x7EA2;&#x8272;</span>
plt.plot([<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>],[<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>],color=<span class="hljs-string">&apos;red&apos;</span>) <span class="hljs-comment">#&#x5C06;&#x989C;&#x8272;&#x8BBE;&#x7F6E;&#x6210;&#x7EA2;&#x8272;</span>
plt.plot([<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>],[<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>],color=<span class="hljs-string">&apos;#000000&apos;</span>) <span class="hljs-comment">#&#x5C06;&#x989C;&#x8272;&#x8BBE;&#x7F6E;&#x6210;&#x7EAF;&#x9ED1;&#x8272;</span>
plt.plot([<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>],[<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>],color=(<span class="hljs-number">0</span>,<span class="hljs-number">0</span>,<span class="hljs-number">0</span>,<span class="hljs-number">0</span>)) <span class="hljs-comment">#&#x5C06;&#x989C;&#x8272;&#x8BBE;&#x7F6E;&#x6210;&#x7EAF;&#x9ED1;&#x8272;</span>
</code></pre>
<p>&#x7ED9;&#x7EBF;&#x6761;&#x8BBE;&#x7F6E;&#x989C;&#x8272;&#x603B;&#x4F53;&#x6765;&#x8BF4;&#x6709;&#x4E09;&#x79CD;&#x65B9;&#x5F0F;&#xFF0C;&#x7B2C;&#x4E00;&#x79CD;&#x662F;&#x4F7F;&#x7528;&#x989C;&#x8272;&#x540D;&#x79F0;&#xFF08;<code>r</code>&#x662F;<code>red</code>&#x7684;&#x7F29;&#x5199;&#xFF09;&#x7684;&#x5F62;&#x5F0F;&#xFF0C;&#x7B2C;&#x4E8C;&#x79CD;&#x662F;&#x4F7F;&#x7528;&#x5341;&#x516D;&#x8FDB;&#x5236;&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x7B2C;&#x4E09;&#x79CD;&#x662F;&#x4F7F;&#x7528;<code>RGB</code>&#x6216;<code>RGBA</code>&#x7684;&#x65B9;&#x5F0F;&#x3002;&#x5982;&#x679C;&#x4F7F;&#x7528;&#x7684;&#x662F;&#x989C;&#x8272;&#x540D;&#x79F0;&#xFF0C;&#x90A3;&#x4E48;&#x53EF;&#x4EE5;&#x548C;&#x7EBF;&#x7684;&#x5F62;&#x72B6;&#x5199;&#x5728;&#x540C;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x3002;&#x6BD4;&#x5982;&#x4F7F;&#x7528;&#x7EA2;&#x8272;&#x7684;&#x4E94;&#x89D2;&#x70B9;&#xFF0C;&#x90A3;&#x4E48;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5982;&#x4E0B;&#x7684;&#x65B9;&#x5F0F;&#x5B9E;&#x73B0;&#xFF1A;</p>
<pre><code class="lang-python">plt.plot([<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>],[<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>],<span class="hljs-string">&apos;rp&apos;</span>) <span class="hljs-comment">#&#x5C06;&#x989C;&#x8272;&#x7EBF;&#x6761;&#x8BBE;&#x7F6E;&#x6210;&#x7EA2;&#x8272;</span>
</code></pre>
<p>&#x5176;&#x4E2D;&#x53EF;&#x4EE5;&#x8868;&#x793A;&#x989C;&#x8272;&#x7684;&#x7F29;&#x5199;&#x5B57;&#x7B26;&#x6709;&#x5982;&#x4E0B;&#xFF1A;</p>
<table>
<thead>
<tr>
<th>&#x5B57;&#x7B26;</th>
<th>&#x989C;&#x8272;</th>
</tr>
</thead>
<tbody>
<tr>
<td>&apos;b&apos;</td>
<td>&#x84DD;&#x8272;&#xFF0C;blue</td>
</tr>
<tr>
<td>&apos;g&apos;</td>
<td>&#x7EFF;&#x8272;&#xFF0C;green</td>
</tr>
<tr>
<td>&apos;r&apos;</td>
<td>&#x7EA2;&#x8272;&#xFF0C;red</td>
</tr>
<tr>
<td>&apos;c&apos;</td>
<td>&#x9752;&#x8272;&#xFF0C;cyan</td>
</tr>
<tr>
<td>&apos;m&apos;</td>
<td>&#x54C1;&#x7EA2;&#xFF0C;magenta</td>
</tr>
<tr>
<td>&apos;y&apos;</td>
<td>&#x9EC4;&#x8272;&#xFF0C;yellow</td>
</tr>
<tr>
<td>&apos;k&apos;</td>
<td>&#x9ED1;&#x8272;&#xFF0C;black</td>
</tr>
<tr>
<td>&apos;w&apos;</td>
<td>&#x767D;&#x8272;&#xFF0C;white</td>
</tr>
</tbody>
</table>
<h2 id="&#x8BBE;&#x7F6E;&#x56FE;&#x7684;&#x4FE1;&#x606F;&#xFF1A;">&#x8BBE;&#x7F6E;&#x56FE;&#x7684;&#x4FE1;&#x606F;&#xFF1A;</h2>
<p>&#x73B0;&#x5728;&#x6211;&#x4EEC;&#x6DFB;&#x52A0;&#x56FE;&#x540E;&#xFF0C;&#x6CA1;&#x6709;&#x6307;&#x5B9A;x&#x8F74;&#x4EE3;&#x8868;&#x4EC0;&#x4E48;&#xFF0C;y&#x8F74;&#x4EE3;&#x8868;&#x4EC0;&#x4E48;&#xFF0C;&#x4EE5;&#x53CA;&#x8FD9;&#x4E2A;&#x56FE;&#x7684;&#x6807;&#x9898;&#x662F;&#x4EC0;&#x4E48;&#x3002;&#x56E0;&#x6B64;&#x4EE5;&#x4E0B;&#x6211;&#x4EEC;&#x901A;&#x8FC7;&#x4E00;&#x4E9B;&#x5C5E;&#x6027;&#x6765;&#x8BBE;&#x7F6E;&#x4E00;&#x4E0B;&#x3002;</p>
<h3 id="&#x8BBE;&#x7F6E;&#x7EBF;&#x6761;&#x6837;&#x5F0F;&#xFF1A;">&#x8BBE;&#x7F6E;&#x7EBF;&#x6761;&#x6837;&#x5F0F;&#xFF1A;</h3>
<ol>
<li>&#x4F7F;&#x7528;<code>plot</code>&#x65B9;&#x6CD5;&#xFF1A;<code>plot</code>&#x65B9;&#x6CD5;&#x5C31;&#x662F;&#x7528;&#x6765;&#x7ED8;&#x5236;&#x7EBF;&#x6761;&#x7684;&#xFF0C;&#x56E0;&#x6B64;&#x53EF;&#x4EE5;&#x5728;&#x7ED8;&#x5236;&#x7684;&#x65F6;&#x5019;&#x5C31;&#x628A;&#x7EBF;&#x6761;&#x76F8;&#x5173;&#x7684;&#x6837;&#x5F0F;&#x901A;&#x8FC7;&#x53C2;&#x6570;&#x4F20;&#x8FDB;&#x53BB;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;<pre><code class="lang-python"> plt.plot(x,y,linewidth=<span class="hljs-number">2</span>)
</code></pre>
</li>
<li>&#x901A;&#x8FC7;<code>Line2D</code>&#x5BF9;&#x8C61;&#x6765;&#x8BBE;&#x7F6E;&#xFF1A;<code>plot</code>&#x65B9;&#x6CD5;&#x4F1A;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x88C5;&#x6709;<code>Line2D</code>&#x5BF9;&#x8C61;&#x7684;&#x5217;&#x8868;&#xFF0C;&#x6BD4;&#x5982;<code>lines=plt.plot(x1,y1,x2,y2)</code>&#x56E0;&#x4E3A;&#x7ED8;&#x5236;&#x4E86;&#x4E24;&#x6839;&#x7EBF;&#x6761;&#xFF0C;&#x56E0;&#x6B64;<code>lines</code>&#x4E2D;&#x4F1A;&#x6709;&#x4E24;&#x4E2A;<code>2D</code>&#x5BF9;&#x8C61;&#x3002;&#x800C;&#x5982;&#x679C;<code>plot</code>&#x53EA;&#x7ED8;&#x5236;&#x4E00;&#x6839;&#x7EBF;&#x6761;&#xFF0C;&#x90A3;&#x4E48;<code>lines</code>&#x4E2D;&#x5C31;&#x53EA;&#x6709;&#x4E00;&#x4E2A;<code>Line2D</code>&#x5BF9;&#x8C61;&#x3002;&#x62FF;&#x5230;&#x8FD9;&#x4E2A;<code>Line2D</code>&#x5BF9;&#x8C61;&#x540E;&#x5C31;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>set_&#x5C5E;&#x6027;&#x540D;</code>&#x8BBE;&#x7F6E;&#x7EBF;&#x6761;&#x7684;&#x6837;&#x5F0F;&#x4E86;&#xFF1A;<pre><code class="lang-python"> lines = plt.plot(x,y)
 line = lines[<span class="hljs-number">0</span>]
 line.set_aa(<span class="hljs-keyword">False</span>) <span class="hljs-comment">#&#x5173;&#x6389;&#x53CD;&#x952F;&#x9F7F;</span>
 line.set_alpha(<span class="hljs-number">0.5</span>) <span class="hljs-comment">#&#x8BBE;&#x7F6E;0.5&#x7684;&#x900F;&#x660E;&#x5EA6;</span>
</code></pre>
</li>
<li>&#x4F7F;&#x7528;<code>plt.setp</code>&#x6765;&#x8BBE;&#x7F6E;&#xFF1A;<code>setp</code>&#x7684;&#x597D;&#x5904;&#x662F;&#x4E00;&#x6B21;&#x6027;&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x591A;&#x6839;&#x7EBF;&#x6761;&#x7684;&#x6837;&#x5F0F;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;<pre><code class="lang-python"> lines = plt.plot(x,y)
 plt.setp(lines,linewidth=<span class="hljs-number">10</span>,alpha=<span class="hljs-number">0.5</span>)
</code></pre>
</li>
<li>&#x66F4;&#x591A;<code>Line2D</code>&#x5C5E;&#x6027;&#xFF1A;
 <img src="../assets/chapter05/Line2D&#x5C5E;&#x6027;&#x8868;.png" alt=""></li>
</ol>
<h3 id="&#x8BBE;&#x7F6E;&#x8F74;&#x548C;&#x6807;&#x9898;&#xFF1A;">&#x8BBE;&#x7F6E;&#x8F74;&#x548C;&#x6807;&#x9898;&#xFF1A;</h3>
<ol>
<li><p>&#x8BBE;&#x7F6E;&#x8F74;&#x540D;&#x79F0;&#xFF1A;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>plt.xlabel</code>&#x548C;<code>plt.ylabel</code>&#x6765;&#x8BBE;&#x7F6E;<code>x</code>&#x8F74;&#x548C;<code>y</code>&#x8F74;&#x7684;&#x7684;&#x540D;&#x79F0;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python"> plt.plot(x,y,linewidth=<span class="hljs-number">10</span>,color=<span class="hljs-string">&apos;red&apos;</span>)
 plt.xlabel(<span class="hljs-string">&quot;x&#x8F74;&quot;</span>)
 plt.ylabel(<span class="hljs-string">&quot;y&#x8F74;&quot;</span>)
</code></pre>
<p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#x662F;&#x663E;&#x793A;&#x4E0D;&#x4E86;&#x4E2D;&#x6587;&#x7684;&#x3002;&#x9700;&#x8981;&#x8BBE;&#x7F6E;&#x5B57;&#x4F53;&#x3002;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4EE5;&#x4E0B;&#x4EE3;&#x7801;&#x6765;&#x5B9E;&#x73B0;&#xFF1A;</p>
<pre><code class="lang-python"> <span class="hljs-comment"># &#x52A0;&#x8F7D;&#x5B57;&#x4F53;</span>
 font = font_manager.FontProperties(fname=<span class="hljs-string">&quot;C:\Windows\Fonts\msyh.ttc&quot;</span>)
 plt.plot(x,y,linewidth=<span class="hljs-number">10</span>,color=<span class="hljs-string">&apos;red&apos;</span>)
 plt.xlabel(<span class="hljs-string">&quot;x&#x8F74;&quot;</span>,fontproperties=font)
 plt.ylabel(<span class="hljs-string">&quot;y&#x8F74;&quot;</span>,fontproperties=font)
</code></pre>
<p>&#x52A0;&#x8F7D;&#x5B57;&#x4F53;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x53EF;&#x4EE5;&#x5230;<code>C:\Windows\Fonts</code>&#x4E2D;&#x627E;&#x4F60;&#x559C;&#x6B22;&#x7684;&#x5E76;&#x4E14;&#x53EF;&#x4EE5;&#x663E;&#x793A;&#x4E2D;&#x6587;&#x7684;&#x5B57;&#x4F53;&#x3002;&#x627E;&#x5230;&#x5B57;&#x4F53;&#x540E;&#xFF0C;&#x8FD8;&#x9700;&#x8981;&#x627E;&#x5230;&#x5B57;&#x4F53;&#x7684;&#x771F;&#x5B9E;&#x540D;&#x79F0;&#x3002;&#x65B9;&#x6CD5;&#x662F;&#x53F3;&#x952E;-&gt;&#x5C5E;&#x6027;-&gt;&#x5B89;&#x5168;-&gt;&#x5BF9;&#x8C61;&#x540D;&#x79F0;&#xFF1A;<br> <img src="../assets/matplotlib3.png" alt=""></p>
</li>
<li><p>&#x8BBE;&#x7F6E;&#x6807;&#x9898;&#xFF1A;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>plt.title</code>&#x65B9;&#x6CD5;&#x6765;&#x5B9E;&#x73B0;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python">font = font_manager.FontProperties(fname=<span class="hljs-string">&quot;C:\Windows\Fonts\msyh.ttc&quot;</span>)
plt.title(<span class="hljs-string">&quot;sin&#x51FD;&#x6570;&quot;</span>,fontproperties=font)
</code></pre>
</li>
<li><p>&#x8BBE;&#x7F6E;<code>x</code>&#x8F74;&#x548C;<code>y</code>&#x8F74;&#x7684;&#x523B;&#x5EA6;&#xFF1A;&#x4E4B;&#x524D;&#x6211;&#x4EEC;&#x753B;&#x7684;&#x56FE;&#xFF0C;<code>x</code>&#x8F74;&#x548C;<code>y</code>&#x8F74;&#x7684;&#x523B;&#x5EA6;&#x90FD;&#x662F;<code>matplotlib</code>&#x81EA;&#x52A8;&#x751F;&#x6210;&#x7684;&#x3002;&#x5982;&#x679C;&#x60F3;&#x8981;&#x5728;&#x751F;&#x6210;&#x56FE;&#x7684;&#x65F6;&#x5019;&#x624B;&#x52A8;&#x7684;&#x6307;&#x5B9A;&#xFF0C;&#x90A3;&#x4E48;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>plt.xticks</code>&#x548C;<code>plt.yticks</code>&#x6765;&#x5B9E;&#x73B0;&#xFF1A;</p>
<pre><code class="lang-python">plt.xticks(range(<span class="hljs-number">0</span>,<span class="hljs-number">20</span>,<span class="hljs-number">2</span>)) <span class="hljs-comment">#&#x5728;x&#x8F74;&#x4E0A;&#x7684;&#x523B;&#x5EA6;&#x662F;0,2,4,6...20</span>
</code></pre>
<p>&#x4EE5;&#x4E0A;&#x4F1A;&#x628A;&#x90A3;&#x4E2A;&#x523B;&#x5EA6;&#x663E;&#x793A;&#x5728;<code>x</code>&#x8F74;&#x4E0A;&#x3002;&#x5982;&#x679C;&#x60F3;&#x8981;&#x663E;&#x793A;&#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;&#xFF0C;&#x90A3;&#x4E48;&#x53EF;&#x4EE5;&#x518D;&#x6784;&#x9020;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;&#xFF0C;&#x8FD9;&#x4E2A;&#x6570;&#x7EC4;&#x7684;&#x957F;&#x5EA6;&#x5FC5;&#x987B;&#x548C;<code>x</code>&#x8F74;&#x523B;&#x5EA6;&#x7684;&#x957F;&#x5EA6;&#x4FDD;&#x6301;&#x4E00;&#x81F4;&#x3002;&#x7136;&#x540E;&#x4F20;&#x7ED9;<code>xticks</code>&#x7684;&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python">_x = range(<span class="hljs-number">0</span>,<span class="hljs-number">20</span>,<span class="hljs-number">2</span>)
_xticks = [<span class="hljs-string">&quot;%d&#x5750;&#x6807;&quot;</span>%i <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> _x]
plt.xticks(_x,_xticks,fontproperties=font) <span class="hljs-comment">#&#x5728;x&#x8F74;&#x4E0A;&#x7684;&#x523B;&#x5EA6;&#x662F;0&#x5750;&#x6807;,2&#x5750;&#x6807;...20&#x5750;&#x6807;</span>
</code></pre>
<p><img src="../assets/matplotlib4.png" alt=""><br>&#x540C;&#x6837;<code>y</code>&#x8F74;&#x7684;&#x523B;&#x5EA6;&#x8BBE;&#x7F6E;&#x4E5F;&#x662F;&#x4E00;&#x6837;&#x7684;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python">_y = np.arange(-<span class="hljs-number">1</span>,<span class="hljs-number">1</span>,<span class="hljs-number">0.25</span>)
_yticks = [<span class="hljs-string">&quot;%.2f&#x70B9;&quot;</span>%i <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> _y]
plt.yticks(_y,_yticks,fontproperties=font)
</code></pre>
<p>&#x6548;&#x679C;&#x56FE;&#x5982;&#x4E0B;&#xFF1A;<br><img src="../assets/matplotlib5.png" alt=""></p>
<p><strong>&#x590D;&#x4EC7;&#x8005;&#x8054;&#x76DF;&#x7535;&#x5F71;&#x7968;&#x623F;&#x6848;&#x4F8B;&#xFF1A;</strong></p>
<pre><code class="lang-python">avenger = [<span class="hljs-number">17974.4</span>,<span class="hljs-number">50918.4</span>,<span class="hljs-number">30033.0</span>,<span class="hljs-number">40329.1</span>,<span class="hljs-number">52330.2</span>,<span class="hljs-number">19833.3</span>,<span class="hljs-number">11902.0</span>,<span class="hljs-number">24322.6</span>,<span class="hljs-number">47521.8</span>,<span class="hljs-number">32262.0</span>,<span class="hljs-number">22841.9</span>,<span class="hljs-number">12938.7</span>,<span class="hljs-number">4835.1</span>,<span class="hljs-number">3118.1</span>,<span class="hljs-number">2570.9</span>,<span class="hljs-number">2267.9</span>,<span class="hljs-number">1902.8</span>,<span class="hljs-number">2548.9</span>,<span class="hljs-number">5046.6</span>,<span class="hljs-number">3600.8</span>]
plt.figure(figsize=(<span class="hljs-number">15</span>,<span class="hljs-number">5</span>))
plt.plot(avenger,marker=<span class="hljs-string">&quot;o&quot;</span>)
font.set_size(<span class="hljs-number">10</span>)
plt.xticks(range(<span class="hljs-number">20</span>),[<span class="hljs-string">&quot;&#x7B2C;%d&#x5929;&quot;</span>%x <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> range(<span class="hljs-number">1</span>,<span class="hljs-number">21</span>)],fontproperties=font)
plt.xlabel(<span class="hljs-string">&quot;&#x5929;&#x6570;&quot;</span>,fontproperties=font)
plt.ylabel(<span class="hljs-string">&quot;&#x7968;&#x623F;&#x6570;(&#x4E07;)&quot;</span>,fontproperties=font)
plt.grid()
</code></pre>
<p><img src="../assets/chapter04/&#x590D;&#x4EC7;&#x8005;&#x8054;&#x76DF;&#x7968;&#x623F;&#x6298;&#x7EBF;&#x56FE;.png" alt=""></p>
</li>
</ol>
<h3 id="&#x8BBE;&#x7F6E;marker&#xFF1A;">&#x8BBE;&#x7F6E;marker&#xFF1A;</h3>
<p>&#x6709;&#x65F6;&#x5019;&#xFF0C;&#x6211;&#x4EEC;&#x60F3;&#x8981;&#x5728;&#x4E00;&#x4E9B;&#x5173;&#x952E;&#x70B9;&#x4E0A;&#x91CD;&#x70B9;&#x6807;&#x8BB0;&#x51FA;&#x6765;&#x3002;&#x90A3;&#x4E48;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8BBE;&#x7F6E;<code>marker</code>&#x6765;&#x5B9E;&#x73B0;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python">x = np.linspace(<span class="hljs-number">0</span>,<span class="hljs-number">20</span>)
y = np.sin(x)
plt.plot(x,y,marker=<span class="hljs-string">&quot;o&quot;</span>)
</code></pre>
<p><img src="../assets/matplotlib2.png" alt=""><br>&#x6211;&#x4EEC;&#x8BBE;&#x7F6E;&#x4E86;<code>marker</code>&#x4E3A;<code>o</code>&#xFF0C;&#x8FD9;&#x6837;&#x5C31;&#x662F;&#x4F1A;&#x5728;<code>(x,y)</code>&#x7684;&#x5750;&#x6807;&#x70B9;&#x4E0A;&#x663E;&#x793A;&#x51FA;&#x6765;&#xFF0C;&#x5E76;&#x4E14;&#x663E;&#x793A;&#x7684;&#x662F;&#x5706;&#x70B9;&#x3002;&#x5176;&#x4E2D;<code>o</code>&#x8DDF;&#x4E4B;&#x524D;&#x7684;&#x7EBF;&#x6761;&#x6837;&#x5F0F;&#x7684;&#x7B80;&#x5199;&#x662F;&#x4E00;&#x6837;&#x7684;&#x3002;&#x53E6;&#x5916;&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>markerfacecolor</code>&#x5C5E;&#x6027;&#x548C;<code>markersize</code>&#x6765;&#x6307;&#x5B9A;&#x6807;&#x8BB0;&#x70B9;&#x7684;&#x989C;&#x8272;&#x548C;&#x5927;&#x5C0F;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python"><span class="hljs-comment"># &#x4EE5;&#x4E0B;&#x8BBE;&#x7F6E;&#x6807;&#x8BB0;&#x70B9;&#x7684;&#x989C;&#x8272;&#x4E3A;&#x9ED1;&#x8272;&#xFF0C;&#x5C3A;&#x5BF8;&#x4E3A;10</span>
plt.plot(x,y,marker=<span class="hljs-string">&quot;o&quot;</span>,markerfacecolor=<span class="hljs-string">&apos;k&apos;</span>,markersize=<span class="hljs-number">10</span>)
</code></pre>
<h3 id="&#x8BBE;&#x7F6E;&#x6CE8;&#x91CA;&#x6587;&#x672C;&#xFF1A;">&#x8BBE;&#x7F6E;&#x6CE8;&#x91CA;&#x6587;&#x672C;&#xFF1A;</h3>
<p>&#x6709;&#x65F6;&#x5019;&#x9700;&#x8981;&#x5728;&#x56FE;&#x5F62;&#x4E2D;&#x7684;&#x67D0;&#x4E2A;&#x70B9;&#x6807;&#x8BB0;&#x6216;&#x8005;&#x6CE8;&#x91CA;&#x4E00;&#x4E0B;&#x3002;&#x90A3;&#x4E48;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>plt.annotate(text,xy,xytext,arrowprops={})</code>&#x6765;&#x5B9E;&#x73B0;&#xFF0C;&#x5176;&#x4E2D;<code>text</code>&#x662F;&#x6CE8;&#x91CA;&#x7684;&#x6587;&#x672C;&#xFF0C;<code>xy</code>&#x662F;&#x9700;&#x8981;&#x6CE8;&#x91CA;&#x7684;&#x70B9;&#x7684;&#x5750;&#x6807;&#xFF0C;<code>xytext</code>&#x662F;&#x6CE8;&#x91CA;&#x6587;&#x672C;&#x7684;&#x5750;&#x6807;&#xFF0C;<code>arrowprops</code>&#x662F;&#x7BAD;&#x5934;&#x7684;&#x6837;&#x5F0F;&#x5C5E;&#x6027;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python">ax = plt.subplot(<span class="hljs-number">111</span>)

x = np.arange(<span class="hljs-number">0.0</span>, <span class="hljs-number">5.0</span>, <span class="hljs-number">0.01</span>)
y = np.cos(<span class="hljs-number">2</span>*np.pi*t)
line, = plt.plot(x, y,linewidth=<span class="hljs-number">2</span>)

plt.annotate(<span class="hljs-string">&apos;local max&apos;</span>, xy=(<span class="hljs-number">2</span>, <span class="hljs-number">1</span>), xytext=(<span class="hljs-number">3</span>, <span class="hljs-number">1.5</span>),
arrowprops=dict(facecolor=<span class="hljs-string">&apos;black&apos;</span>,shrink=<span class="hljs-number">0.05</span>),
)

plt.ylim(-<span class="hljs-number">2</span>, <span class="hljs-number">2</span>)
plt.show()
</code></pre>
<h3 id="&#x8BBE;&#x7F6E;&#x56FE;&#x5F62;&#x6837;&#x5F0F;&#xFF1A;">&#x8BBE;&#x7F6E;&#x56FE;&#x5F62;&#x6837;&#x5F0F;&#xFF1A;</h3>
<p>&#x5982;&#x679C;&#x60F3;&#x8981;&#x8C03;&#x6574;&#x56FE;&#x7247;&#x7684;&#x5927;&#x5C0F;&#x548C;&#x50CF;&#x7D20;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>plt.figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True)</code>&#x6765;&#x5B9E;&#x73B0;&#x3002;<br>&#x5176;&#x4E2D;<code>num</code>&#x662F;&#x56FE;&#x7684;&#x7F16;&#x53F7;&#xFF0C;<code>figsize</code>&#x7684;&#x5355;&#x4F4D;&#x662F;&#x82F1;&#x5BF8;&#xFF0C;<code>dpi</code>&#x662F;&#x6BCF;&#x82F1;&#x5BF8;&#x7684;&#x50CF;&#x7D20;&#x70B9;&#xFF0C;<code>facecolor</code>&#x662F;&#x56FE;&#x7247;&#x80CC;&#x666F;&#x989C;&#x8272;&#xFF0C;<code>edgecolor</code>&#x662F;&#x8FB9;&#x6846;&#x989C;&#x8272;&#xFF0C;<code>frameon</code>&#x4EE3;&#x8868;&#x662F;&#x5426;&#x7ED8;&#x5236;&#x753B;&#x677F;&#x3002;<br>&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python">plt.figure(figsize=(<span class="hljs-number">20</span>,<span class="hljs-number">8</span>),dpi=<span class="hljs-number">80</span>)
<span class="hljs-comment"># &#x5176;&#x4ED6;&#x7684;&#x7ED8;&#x5236;&#x56FE;&#x5F62;&#x7684;&#x4EE3;&#x7801;</span>
</code></pre>
<p>&#x6211;&#x4EEC;&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>grid</code>&#x65B9;&#x6CD5;&#xFF0C;&#x6765;&#x663E;&#x793A;&#x56FE;&#x7247;&#x7684;&#x7F51;&#x683C;&#xFF1A;</p>
<pre><code class="lang-python">plt.plot(x,y,color=<span class="hljs-string">&quot;r&quot;</span>)
plt.grid()
</code></pre>
<p><img src="../assets/matplotlib9.png" alt=""></p>
<h3 id="&#x4FDD;&#x5B58;&#x56FE;&#x7247;&#xFF1A;">&#x4FDD;&#x5B58;&#x56FE;&#x7247;&#xFF1A;</h3>
<p>&#x53EF;&#x4EE5;&#x8C03;&#x7528;<code>plt.savefig(path)</code>&#x6765;&#x4FDD;&#x5B58;&#x5F53;&#x524D;&#x7684;&#x56FE;&#x7247;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python">plt.savefig(<span class="hljs-string">&quot;./abc.png&quot;</span>)
</code></pre>
<hr>
<h2 id="&#x7ED8;&#x5236;&#x591A;&#x4E2A;&#x56FE;&#xFF1A;">&#x7ED8;&#x5236;&#x591A;&#x4E2A;&#x56FE;&#xFF1A;</h2>
<p>&#x7ED8;&#x5236;&#x591A;&#x4E2A;&#x56FE;&#x6709;&#x4E24;&#x79CD;&#x5F62;&#x5F0F;&#xFF0C;&#x7B2C;&#x4E00;&#x79CD;&#x5F62;&#x5F0F;&#x662F;&#x5728;&#x4E00;&#x5F20;&#x56FE;&#x4E2D;&#x7ED8;&#x5236;&#x591A;&#x8DDF;&#x7EBF;&#x6761;&#xFF0C;&#x7B2C;&#x4E8C;&#x79CD;&#x5F62;&#x5F0F;&#x662F;&#x7ED8;&#x5236;&#x591A;&#x4E2A;&#x5B50;&#x56FE;&#x5F62;&#x3002;&#x4EE5;&#x4E0B;&#x5206;&#x522B;&#x8FDB;&#x884C;&#x8BB2;&#x89E3;&#x3002;</p>
<h3 id="&#x7ED8;&#x5236;&#x591A;&#x6839;&#x6298;&#x7EBF;&#xFF1A;">&#x7ED8;&#x5236;&#x591A;&#x6839;&#x6298;&#x7EBF;&#xFF1A;</h3>
<p>&#x7ED8;&#x5236;&#x591A;&#x6839;&#x7EBF;&#x6761;&#xFF0C;&#x53EA;&#x8981;&#x51C6;&#x5907;&#x597D;&#x5750;&#x6807;&#xFF0C;&#x91CD;&#x65B0;&#x4F7F;&#x7528;<code>plt.plot</code>&#x7ED8;&#x5236;&#x5373;&#x53EF;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> matplotlib <span class="hljs-keyword">import</span> font_manager
x = np.linspace(<span class="hljs-number">0</span>,<span class="hljs-number">20</span>)
y = np.sin(x)
z = np.cos(x)
font = font_manager.FontProperties(fname=<span class="hljs-string">&quot;C:\Windows\Fonts\msyh.ttc&quot;</span>)
plt.xlabel(<span class="hljs-string">&quot;x&#x8F74;&quot;</span>,fontproperties=font)
plt.ylabel(<span class="hljs-string">&quot;y&#x8F74;&quot;</span>,fontproperties=font)
_x = range(<span class="hljs-number">0</span>,<span class="hljs-number">20</span>,<span class="hljs-number">2</span>)
_xticks = [<span class="hljs-string">&quot;%s&#x70B9;&quot;</span>%i <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> _x]
plt.xticks(range(<span class="hljs-number">0</span>,<span class="hljs-number">20</span>,<span class="hljs-number">2</span>),_xticks,fontproperties=font,rotation=<span class="hljs-number">45</span>)
_y = list(np.range(-<span class="hljs-number">1</span>,<span class="hljs-number">1</span>,<span class="hljs-number">0.25</span>))
_yticks = [<span class="hljs-string">&quot;%.2f&#x70B9;&quot;</span>%i <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> _y]
plt.yticks(_y,_yticks,fontproperties=font)
plt.plot(x,y)
plt.plot(x,z)
</code></pre>
<p>&#x793A;&#x4F8B;&#x56FE;&#x5982;&#x4E0B;&#xFF1A;<br><img src="../assets/matplotlib7.png" alt=""></p>
<h3 id="&#x7ED8;&#x5236;&#x591A;&#x4E2A;&#x5B50;&#x56FE;&#xFF1A;">&#x7ED8;&#x5236;&#x591A;&#x4E2A;&#x5B50;&#x56FE;&#xFF1A;</h3>
<p>&#x7ED8;&#x5236;&#x5B50;&#x56FE;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>plt.subplot</code>&#x6216;<code>plt.subplots</code>&#x6765;&#x5B9E;&#x73B0;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python">plt.subplot(<span class="hljs-number">221</span>)
plt.plot(np.arange(<span class="hljs-number">10</span>),c=<span class="hljs-string">&apos;r&apos;</span>)
plt.subplot(<span class="hljs-number">222</span>)
plt.plot(np.sin(np.arange(<span class="hljs-number">10</span>)),c=<span class="hljs-string">&apos;b&apos;</span>)
plt.subplot(<span class="hljs-number">223</span>)
plt.plot(np.cos(np.arange(<span class="hljs-number">10</span>)),c=<span class="hljs-string">&apos;y&apos;</span>)
plt.subplot(<span class="hljs-number">224</span>)
plt.plot(np.tan(np.arange(<span class="hljs-number">10</span>)),c=<span class="hljs-string">&apos;g&apos;</span>)
</code></pre>
<p>&#x6548;&#x679C;&#x56FE;&#x5982;&#x4E0B;&#xFF1A;<br><img src="../assets/chapter04/subplot1.png" alt=""><br>&#x5176;&#x4E2D;<code>subplot</code>&#x4E2D;&#x7684;<code>211</code>&#x548C;<code>212</code>&#x5206;&#x522B;&#x4EE3;&#x8868;&#x7684;&#x610F;&#x601D;&#x662F;&#xFF0C;&#x7B2C;&#x4E00;&#x4E2A;&#x6570;&#x8868;&#x793A;&#x8FD9;&#x4E2A;&#x5927;&#x56FE;&#x4E2D;&#x603B;&#x5171;&#x6709;<code>2</code>&#x884C;&#xFF0C;&#x7B2C;&#x4E8C;&#x4E2A;&#x6570;&#x8868;&#x793A;&#x603B;&#x5171;&#x6709;<code>1</code>&#x5217;&#xFF0C;&#x7136;&#x540E;&#x7B2C;&#x4E09;&#x4E2A;&#x6570;&#x8868;&#x793A;&#x5F53;&#x524D;&#x7ED8;&#x5236;&#x7B2C;&#x51E0;&#x4E2A;&#x56FE;&#x3002;</p>
<p>&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>fig,axs=plt.subplots(rows,cols,*args,**kwargs)</code>&#x6765;&#x7ED8;&#x5236;&#x591A;&#x4E2A;&#x56FE;&#x5F62;&#xFF0C;&#x8FD4;&#x56DE;&#x503C;&#x662F;&#x4E00;&#x4E2A;&#x5143;&#x7EC4;&#xFF0C;&#x5176;&#x4E2D;&#x7684;<code>fig</code>&#x53C2;&#x6570;&#x662F;<code>figure</code>&#x5BF9;&#x8C61;&#xFF0C;<code>axs</code>&#x662F;<code>axes</code>&#x5BF9;&#x8C61;&#x7684;<code>array</code>&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python">figure,axes = plt.subplots(<span class="hljs-number">2</span>,<span class="hljs-number">2</span>)
axes[<span class="hljs-number">0</span>,<span class="hljs-number">0</span>].plot(np.sin(np.arange(<span class="hljs-number">10</span>)),c=<span class="hljs-string">&apos;r&apos;</span>)
axes[<span class="hljs-number">0</span>,<span class="hljs-number">1</span>].plot(np.cos(np.arange(<span class="hljs-number">10</span>)),c=<span class="hljs-string">&apos;b&apos;</span>)
axes[<span class="hljs-number">1</span>,<span class="hljs-number">0</span>].plot(np.tan(np.arange(<span class="hljs-number">10</span>)),c=<span class="hljs-string">&apos;y&apos;</span>)
axes[<span class="hljs-number">1</span>,<span class="hljs-number">1</span>].plot(np.arange(<span class="hljs-number">10</span>),c=<span class="hljs-string">&apos;g&apos;</span>)
</code></pre>
<p>&#x6548;&#x679C;&#x56FE;&#x8DDF;&#x4E4B;&#x524D;&#x4F7F;&#x7528;<code>plt.subplot</code>&#x4E00;&#x6837;&#x3002;&#x53E6;&#x5916;&#x4F7F;&#x7528;<code>subplot</code>&#x548C;<code>subplots</code>&#x90FD;&#x53EF;&#x4EE5;&#x4F20;&#x9012;<code>sharex/sharey</code>&#x53C2;&#x6570;&#xFF0C;&#x8FD9;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#x8868;&#x793A;&#x662F;&#x5426;&#x9700;&#x8981;&#x5171;&#x4EAB;X&#x8F74;&#x548C;Y&#x8F74;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python">figure,axes = plt.subplots(<span class="hljs-number">2</span>,<span class="hljs-number">2</span>,sharex=<span class="hljs-keyword">True</span>,sharey=<span class="hljs-keyword">True</span>)
axes[<span class="hljs-number">0</span>,<span class="hljs-number">0</span>].plot(np.sin(np.arange(<span class="hljs-number">10</span>)),c=<span class="hljs-string">&apos;r&apos;</span>)
axes[<span class="hljs-number">0</span>,<span class="hljs-number">1</span>].plot(np.cos(np.arange(<span class="hljs-number">10</span>)),c=<span class="hljs-string">&apos;b&apos;</span>)
axes[<span class="hljs-number">1</span>,<span class="hljs-number">0</span>].plot(np.tan(np.arange(<span class="hljs-number">10</span>)),c=<span class="hljs-string">&apos;y&apos;</span>)
axes[<span class="hljs-number">1</span>,<span class="hljs-number">1</span>].plot(np.arange(<span class="hljs-number">10</span>),c=<span class="hljs-string">&apos;g&apos;</span>)
</code></pre>
<p><img src="../assets/chapter04/subplot2.png" alt=""></p>
<h3 id="&#x98CE;&#x683C;&#x8BBE;&#x7F6E;&#xFF1A;">&#x98CE;&#x683C;&#x8BBE;&#x7F6E;&#xFF1A;</h3>
<p><code>matplotlib</code>&#x56FE;&#x7247;&#x9ED8;&#x8BA4;&#x5185;&#x7F6E;&#x4E86;&#x51E0;&#x79CD;&#x98CE;&#x683C;&#x3002;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>plt.style.available</code>&#x6765;&#x67E5;&#x770B;&#x5185;&#x7F6E;&#x7684;&#x6240;&#x6709;&#x98CE;&#x683C;:</p>
<pre><code class="lang-python">[<span class="hljs-string">&apos;bmh&apos;</span>,
<span class="hljs-string">&apos;classic&apos;</span>,
<span class="hljs-string">&apos;dark_background&apos;</span>,
<span class="hljs-string">&apos;fast&apos;</span>,
<span class="hljs-string">&apos;fivethirtyeight&apos;</span>,
<span class="hljs-string">&apos;ggplot&apos;</span>,
<span class="hljs-string">&apos;grayscale&apos;</span>,
<span class="hljs-string">&apos;seaborn-bright&apos;</span>,
<span class="hljs-string">&apos;seaborn-colorblind&apos;</span>,
<span class="hljs-string">&apos;seaborn-dark-palette&apos;</span>,
<span class="hljs-string">&apos;seaborn-dark&apos;</span>,
<span class="hljs-string">&apos;seaborn-darkgrid&apos;</span>,
<span class="hljs-string">&apos;seaborn-deep&apos;</span>,
<span class="hljs-string">&apos;seaborn-muted&apos;</span>,
<span class="hljs-string">&apos;seaborn-notebook&apos;</span>,
<span class="hljs-string">&apos;seaborn-paper&apos;</span>,
<span class="hljs-string">&apos;seaborn-pastel&apos;</span>,
<span class="hljs-string">&apos;seaborn-poster&apos;</span>,
<span class="hljs-string">&apos;seaborn-talk&apos;</span>,
<span class="hljs-string">&apos;seaborn-ticks&apos;</span>,
<span class="hljs-string">&apos;seaborn-white&apos;</span>,
<span class="hljs-string">&apos;seaborn-whitegrid&apos;</span>,
<span class="hljs-string">&apos;seaborn&apos;</span>,
<span class="hljs-string">&apos;Solarize_Light2&apos;</span>,
<span class="hljs-string">&apos;tableau-colorblind10&apos;</span>,
<span class="hljs-string">&apos;_classic_test&apos;</span>]
</code></pre>
<p>&#x5728;&#x7ED8;&#x5236;&#x7684;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>plt.style.use</code>&#x65B9;&#x6CD5;&#x6765;&#x4F7F;&#x7528;&#x4E0D;&#x540C;&#x7684;&#x98CE;&#x683C;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python">plt.style.use(<span class="hljs-string">&quot;dark_background&quot;</span>)
</code></pre>
<h2 id="&#x5B98;&#x65B9;&#x6587;&#x6863;&#x4ECB;&#x7ECD;&#xFF1A;">&#x5B98;&#x65B9;&#x6587;&#x6863;&#x4ECB;&#x7ECD;&#xFF1A;</h2>
<ol>
<li><code>plt.plot</code>&#x4F7F;&#x7528;&#x8BE6;&#x89E3;&#xFF1A;<a href="https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html#matplotlib.pyplot.plot" target="_blank">https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html#matplotlib.pyplot.plot</a></li>
<li><code>matplotlib.pyplot</code>&#x4F7F;&#x7528;&#x8BE6;&#x89E3;&#xFF1A;<a href="https://matplotlib.org/api/pyplot_summary.html" target="_blank">https://matplotlib.org/api/pyplot_summary.html</a></li>
<li><code>matplotlib</code>&#x5185;&#x7F6E;&#x7684;&#x6837;&#x5F0F;&#xFF1A;<a href="https://tonysyu.github.io/raw_content/matplotlib-style-gallery/gallery.html" target="_blank">https://tonysyu.github.io/raw_content/matplotlib-style-gallery/gallery.html</a></li>
</ol>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../chapter4/01常用图.html" class="navigation navigation-prev " aria-label="Previous page: 第1节：常用图"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../chapter4/03条形图.html" class="navigation navigation-next " aria-label="Next page: 第3节：条形图"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
